<?php
if(!check_manager_login()) exit('无权查看，请登录!');
require_once(MODEL_PATH.DS.'News.php');
$News = new News();
if(check_post()){
	$news_cate = $_POST['news_cate'];
	$title = trim($_POST['news_title']);
	$short_desc = trim($_POST['short_desc']);
	$description = trim($_POST['description']);
	$msg = array();
	$error = false;
	if(empty($title)){
		$msg[] = '新闻标题不能为空！';
		$error = true;
	}
	if(empty($description)){
		$msg[] = '新闻内容不能为空！';
		$error = true;
	}
	if(!$error){
		$data = array(
			'cate_id'=>$news_cate,
			'title'=>$title,
			'short_desc'=>$short_desc,
			'description'=>$description,
			'created'=>date('Y-m-d H:i:s'),
		);
		$result = $News->addNews($data);
		if($result){
			redirect('index.php?mod=news&act=list','添加新闻成功!');
		}
	}
}

$cate_all = $News->getAllNewsCate();
$cate_select = create_select($cate_all,'id','name');


include load_tpl('news_add');
?>